home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Scripts / MEMACS-ShowError < prev    next >
Text File  |  1991-09-03  |  4KB  |  145 lines

  1. /*
  2.  
  3. MEMACS-ShowError
  4.  
  5. This Arexx program displays the errors generated by the PCQ Pascal
  6. compiler using the MEMACS text editor from Commodore.  It should
  7. be called as follows:
  8.  
  9.     MEMACS-ShowError SourceFile OutputFile ErrorFile
  10.  
  11. MEMACS-ShowError reads the errorfile, which must have been
  12. generated by PCQ Pascal in "quiet" mode.  It displays the first
  13. error in the appropriate source file (not necessarily the
  14. SourceFile), then erases the OutputFile and ErrorFile.
  15.  
  16. This file was designed to be an error handler for the PCQ make
  17. utility.  It might work for other purposes, but I'd be careful if
  18. I were you.
  19.  
  20. To use this program, you'll need to include the following line in
  21. your configuration file:
  22.  
  23.     CompilerError rx MEMACS-ShowError \s \d \e
  24.  
  25. Then you need to add the following line to your S:Emacs_pro file
  26. (the configuration file for MEMACS):
  27.  
  28.     execute-file S:PCQ-Error
  29.  
  30. Finally, you'll need to create the S:PCQ-Error file.  Normally this
  31. will just be a dummy statement, but it will be replaced by a more
  32. complete series of commands by this file.  I would suggest creating
  33. a S:PCQ-Error file with the following contents:
  34.  
  35.     show-line#
  36.  
  37.  
  38. You'll also need MEMACS and Arexx.  Arexx is, of course, a
  39. commercial program, and MEMACS is one of the text editors supplied
  40. by Commodore with AmigaDOS.  It's in the Tools directory.  If you
  41. have AmigaDOS 2.0, both of these programs are supplied.
  42.  
  43. */
  44.  
  45. /* Read the command line parameters */
  46.  
  47. parse arg SourceFileName OutputFileName ErrorFileName .
  48.  
  49. options results
  50.  
  51.  
  52. /* Get the first error */
  53.  
  54. if open(logfile, ErrorFileName, 'R') then do
  55.  
  56.     if eof(logfile) then do   /* There were no errors */
  57.     FileName = SourceFileName
  58.     LineNo = 1
  59.     ColumnNo = 1
  60.     end; else do
  61.         ErrorString = readln(logfile)
  62.  
  63.         /* This first test is just a reminder, in case you want to */
  64.         /* process all errors.  "Abort" would never come first.    */
  65.  
  66.         if ErrorString = "Compilation Aborted" then do
  67.             address command 'delete >nil:' outputfile
  68.             'okay1 Compilation Aborted'
  69.             exit
  70.         end
  71.  
  72.         if ErrorString ~= "" then do
  73.             parse var ErrorString '"' FileName '" At ' LineNo,
  74.                                        ',' ColumnNo .
  75.     end; else do
  76.         FileName = SourceFileName
  77.         LineNo = 1
  78.         ColumnNo = 1
  79.     end
  80.     end
  81.     close(logfile)
  82. end; else do
  83.     say 'Could not open error file'
  84.     exit
  85. end
  86.  
  87. RightMost = max(pos('/',ErrorFileName),pos(':',ErrorFileName))
  88. JustErrorName = substr(ErrorFileName,RightMost+1)
  89.  
  90. RightMost = max(pos('/',FileName),pos(':',FileName))
  91. JustFileName = substr(FileName,RightMost+1)
  92.  
  93. if open(logfile, 'S:PCQ-Error', 'W') then do
  94.  
  95.     writeln(logfile, 'visit-file' ErrorFileName);
  96.  
  97.     writeln(logfile, 'split-window');
  98.     writeln(logfile, 'select-buffer' strip(left(JustFileName,15)));
  99.  
  100.     writeln(logfile, 'next-window');
  101.  
  102.  
  103. /* The version of MEMACS I'm currently using can't seem to */
  104. /* handle the shrink-window command in a file, and it does */
  105. /* bizarre things with forw-char.  Therefore they are both */
  106. /* commented out.                                          */
  107.  
  108. /*    do for 6
  109.     writeln(logfile, 'shrink-window');
  110.     end; */
  111.  
  112.     writeln(logfile, 'prev-window');
  113.     writeln(logfile, 'goto-line' LineNo);
  114.     writeln(logfile, 'start-of-line');
  115.  
  116. /*    do for ColumnNo
  117.     writeln(logfile, 'forw-char');
  118.     end; */
  119.  
  120.     close(logfile);
  121. end; else do
  122.     say 'Could not open command file'
  123. end;
  124.  
  125.  
  126. /* Load MEMACS */
  127.  
  128. address command memacs FileName
  129.  
  130. /* After it quits, reset the command file and delete the */
  131. /* temporary files.                                      */
  132.  
  133. if open(logfile, 'S:PCQ-Error', 'W') then do
  134.     Writeln(logfile, 'show-line#');
  135.     close(logfile);
  136. end; else do
  137.     say 'Error writing to command file';
  138. end;
  139.  
  140. /* Delete the temporary files */
  141.  
  142. address command 'delete >Nil:' ErrorFileName
  143. address command 'delete >Nil:' OutputFileName
  144.  
  145.